package org.jsbd.boss.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.dao.IDouyingActionStepConfigDao;
import org.jsbd.boss.domian.DouyingActionStep;
import org.jsbd.boss.service.IDouyingActionStepConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("douyingActionStepConfigService")
public class DouyingActionStepConfigServiceImpl implements IDouyingActionStepConfigService{

	@Autowired
	private IDouyingActionStepConfigDao douyingActionStepConfigDao;
	
	@Override
	public Map<String, Object> getListPage(DataGridModel page, DouyingActionStep douyingActionStep) {
		douyingActionStep = (douyingActionStep == null ? new DouyingActionStep() : douyingActionStep);
		douyingActionStep.setPageInfo(page);
		Map<String, Object> results = new HashMap<String, Object>();
		results.put("total", douyingActionStepConfigDao.getListPageCount(douyingActionStep));
		
		List<DouyingActionStep> list = (List<DouyingActionStep>) douyingActionStepConfigDao.getList(douyingActionStep);
		for (DouyingActionStep config : list) {
			config.setCreateDate(org.jsbd.boss.util.DateUtil.getYmdhmsDateStr(config.getCreateTime()));
			config.setModifyDate(org.jsbd.boss.util.DateUtil.getYmdhmsDateStr(config.getModifyTime()));
		}
		results.put("rows", list);
		return results;
	}

	@Override
	public void save(DouyingActionStep douyingActionStep) {
		douyingActionStepConfigDao.insert(douyingActionStep);
	}

	@Override
	public void update(DouyingActionStep douyingActionStep) {
		douyingActionStepConfigDao.update(douyingActionStep);
		
	}

	@Override
	public void delete(List<Integer> ids) {
		douyingActionStepConfigDao.delete(ids);
	}

}
